// 引入所需的外部模块  这里不能使用 根路径 '/'
var common = require('../../../utils/util.js')
const appInstance = getApp()
console.log(appInstance.globalData) // I am global data
Page({
  /**
   * 页面的初始数据
   */
  data: {
    head_img:"",
    name_message:"",
    account_notice:"账号: ",
    account_number:"",
    // 用于展示个人资料页面的功能项
    show_function:[
      {icon:"/images/personal/circle_friends.png",name:"朋友圈",pagePath:"/pages/personal/friend_circle/index"},
      {icon:"/images/personal/customer_service.png",name:"客服",pagePath:"/pages/personal/custome_service/index"},
      {icon:"/images/personal/person_message.png",name:"个人资料",pagePath:"/pages/personal/person_message/index"},
      {icon:"/images/personal/set_up.png",name:"设置",pagePath:"/pages/personal/set_up/index"},
      {icon:"/images/personal/logout.png",name:"退出",pagePath:"/pages/personal/logout/index"},
    ]
  },
  /**
   *  为了及时更新页面信息需要写在onShow()里面   
   *  注意：onLoad():只要页面不卸载，只会加载一次
   */ 
  onLoad(){
    var value = wx.getStorageSync('hasLogin')
    if(value=='' || value==false ){
      wx.redirectTo({
        url: '/pages/login/index',
        success:function(e){
            console.log("成功跳转到登录界面")
        },
        fail:function(error){
          console.log("跳转失败--app.js")
        }
      })
    }
  },
  onShow:function(){
   console.log('个人中心页面加载了')
   var that=this
   var userobj={}   
  // 获取用户基本信息  从服务器获取之前先查看本地
  var userBasicMessage=wx.getStorageSync('basicMessage')
  console.log("获取信息 *******  userBasicMessage= "+userBasicMessage)
  if(userBasicMessage!='' || userBasicMessage!=null ){
    console.log("本地有用户的基本信息 ******* ")
    that.setData({
      name_message:userBasicMessage.signature,
      account_number:userBasicMessage.username
    })
  }else{
    console.log('本地没有用户的基本信息')
  }
  },  
  })
 
